import 'dart:convert';

import 'package:bruno/bruno.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../AppConfig/Config.dart';
import '../AppConfig/LocalStorage.dart';
import '../http/api.dart';

class ECargoInsurance extends StatefulWidget {
  const ECargoInsurance({super.key, required this.insureList});
  final List insureList;
  @override
  State<ECargoInsurance> createState() => _ECargoInsuranceState();
}

class _ECargoInsuranceState extends State<ECargoInsurance> {
  List moneyList=['5万',"10万","20万","50万"];
  String chooseMoney="";
  List personList=["本人","司机"];
  List payPersonList=['个人',"企业"];
  List payForList=['同投保人',"其他-个人","其他-企业"];
  String payPerson="";
  String insuredPerson="";
  String isAgree = "0";
  Map userMap={};
  Map insureMap={};
  List insureMsgList=["","","","",""];
  List PayPersonMesList=["","",""];
  List PayForMesList=["","",""];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserMessage();
    getinsureMessage();
    if(widget.insureList.isNotEmpty){
      insureMsgList=widget.insureList;
      chooseMoney=insureMsgList[0];
      payPerson=insureMsgList[3];
      insuredPerson=insureMsgList[4];
      PayPersonMesList=insureMsgList[1];
      PayForMesList=insureMsgList[2];
    }
  }
  void getinsureMessage() async {
    String? token= await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));

    dio.get<String>(MyServiceUrl.header+'api/system/dev/insurance/page?current=1&size=20')
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());

        // 获取code和data
        String code = jsonMap['code'].toString();
        if (code == "200") {
          setState(() {
            insureMap=jsonMap['data']['records'][0];
          });
        } else {}
        // 打印结果
        print('Code: $code');
      });
    }).catchError((error) {
      print(error);
    });
  }
  void getUserMessage() async {
    String? token= await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));

    dio.get<String>(MyServiceUrl.header+'api/auth/shipper/user/getLoginUser')
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());

        // 获取code和data
        String code = jsonMap['code'].toString();
        if (code == "200") {
          setState(() {
            userMap=jsonMap['data'];
          });
        } else {}
        // 打印结果
        print('Code: $code');
      });
    }).catchError((error) {
      print(error);
    });
  }
  late TextEditingController _moneyText = TextEditingController(text: chooseMoney.contains("5")||chooseMoney.contains("10")||chooseMoney.contains("20")||chooseMoney.contains("50")?"":chooseMoney.replaceAll("万", ""));
  late TextEditingController _payNameText = TextEditingController(text:PayPersonMesList[0] );
  late TextEditingController _forNameText = TextEditingController(text: PayForMesList[0]);
  late TextEditingController _payNumText = TextEditingController(text: PayPersonMesList[1]);
  late TextEditingController _forNumText = TextEditingController(text: PayForMesList[1]);
  late TextEditingController _payPhoneText = TextEditingController(text: PayForMesList[2]);
  late TextEditingController _forPhoneText = TextEditingController(text: PayForMesList[2]);
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        title:Text( "货运险",style: TextStyle(fontWeight: FontWeight.w300,fontSize: 16.sp),),
        backgroundColor: Colors.white,
        centerTitle: true,
      ),
      body: Column(
        children: [
          Expanded(child: ListView(
            children: [
              Image.asset("lib/Images/OrderList/货运险展示图.png",width: screenSize.width,height: 210.h,),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(top: 15.h,bottom: 18.h,left: 18.w,right: 18.w),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("完善货物价值（保额）",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),

                    Text(insureMap.isEmpty?"":"费率${(double.parse(insureMap['rates'])*100).toString()}%",style: TextStyle(color: MyColors.textColor),),
                  ],
                ),
                SizedBox(height: 26.h,),
                Wrap(
                  spacing: 8.0, // 两个Container之间的水平间距
                  runSpacing: 10.0, // 行与行之间的垂直间距
                  children: moneyList.map((length) {
                    bool? isSelected = chooseMoney.contains(length);

                    return GestureDetector(
                      onTap: () {
                        // 处理点击事件
                        setState(() {
                          if (isSelected) {
                            //如果已经被选中，则移除
                         chooseMoney="";

                          } else {
                            // 如果未被选中且未达到最大选择数量，则添加
                            chooseMoney=length;
                          }
                        });
                      },
                      child: Container(
                        width: 70.w, // Container宽度
                        height: 30.h, // Container高度，使其成为正方形
                        decoration: BoxDecoration(
                          border: Border.all(
                            color: isSelected ?MyColors.themeColor:MyColors.backgreyColor , // 边框颜色
                            width: 1.0, // 边框宽度
                          ),
                          color: isSelected ? Color.fromRGBO(251, 236, 228, 1) : MyColors.backgreyColor, // 根据状态决定颜色
                          borderRadius: BorderRadius.circular(3.0), // 设置Container的圆角
                        ),
                        child: Center(
                          child: Text(
                            length,
                            style: TextStyle(
                              fontSize: 13.sp,
                              color: isSelected ?MyColors.themeColor:Colors.black, // 文字颜色为白色
                            ),
                          ),
                        ),
                      ),
                    );
                  }).toList(),
                ),
                SizedBox(height: 20.h,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("其他保额",style: TextStyle(color: Colors.black),),
                    Container(
                      height: 30.h,
                      width: screenSize.width-150.w,
                      color: Color.fromRGBO(248, 248, 248, 1),
                      padding: EdgeInsets.only(right: 8.w),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Container(
                            height: 30.h,
                            width: 170.w,
                            alignment: Alignment.centerLeft,
                            child:TextField(
                              style: TextStyle(color: Colors.black),
                              keyboardType: TextInputType.number,
                              controller: _moneyText,
                              decoration: InputDecoration(
                                filled: true,
                                fillColor: Color.fromRGBO(248, 248, 248, 1),
                                hintText:"最低5万，最高200万",
                                //边框
                                focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Color.fromRGBO(248, 248, 248, 1))),
                                enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color:Color.fromRGBO(248, 248, 248, 1),)),
                                hintStyle: TextStyle(
                                  color: Color.fromRGBO(183, 183, 183, 1),
                                  fontSize: MyFontSizes.commonrText.sp,
                                ),
                              ),
                              onChanged: (value) {
                                setState(() {
                                  chooseMoney = value;
                                });
                              },

                            ),
                          ),
                          Text("万",style: TextStyle(color: Colors.black),),
                        ],
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
              Container(
                margin: EdgeInsets.only(left: 10.w,right: 10.w),
                height: 8.h,
                color: Color.fromRGBO(240, 240, 240, 1),
              ),
              Container(
                margin: EdgeInsets.only(left: 10.w,right: 10.w,),
                padding: EdgeInsets.only(top: 12.h,bottom: 18.h,left: 18.w,right: 18.w),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.all(Radius.circular(10))),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text("谁买保险（投保人）",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                    SizedBox(height: 12.h,),
                    Wrap(
                      spacing: 12.0, // 两个Container之间的水平间距
                      runSpacing: 10.0, // 行与行之间的垂直间距
                      children: payPersonList.map((length) {
                        bool? isSelected = payPerson.contains(length);

                        return GestureDetector(
                          onTap: () {
                            // 处理点击事件
                            setState(() {
                              if (isSelected) {
                                //如果已经被选中，则移除
                                payPerson="";

                              } else {
                                // 如果未被选中且未达到最大选择数量，则添加
                                payPerson=length;

                              }
                            });
                          },
                          child: Container(
                            width: 140.w, // Container宽度
                            height: 30.h, // Container高度，使其成为正方形
                            decoration: BoxDecoration(
                              border: Border.all(
                                color: isSelected ?MyColors.themeColor:MyColors.backgreyColor , // 边框颜色
                                width: 1.0, // 边框宽度
                              ),
                              color: isSelected ? Color.fromRGBO(251, 236, 228, 1) : MyColors.backgreyColor, // 根据状态决定颜色
                              borderRadius: BorderRadius.circular(3.0), // 设置Container的圆角
                            ),
                            child: Center(
                              child: Text(
                                length,
                                style: TextStyle(
                                  fontSize: 13.sp,
                                  color: isSelected ?MyColors.themeColor:Colors.black, // 文字颜色为白色
                                ),
                              ),
                            ),
                          ),
                        );
                      }).toList(),
                    ),
                    SizedBox(height: 20.h,),
                    Column(
                      children: [
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child:Text(payPerson=="个人"?"姓名":"公司名称",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:payPerson=="个人"?'请输入姓名': '请输入企业名称',
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _payNameText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayPersonMesList[0]=value;
                                  });
                                },
                              ),
                            ),
                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child: Text(payPerson=="个人"?"身份证":"统一社会信用代码",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:payPerson=="个人"?'请输入身份证号': '请输入信用代码',
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _payNumText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayPersonMesList[1]=value;
                                  });
                                },
                              ),
                            ),

                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child: Text("手机号",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:"请输入手机号",
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _payPhoneText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayPersonMesList[2]=value;
                                  });
                                },
                              ),
                            ),

                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                      ],
                    ),

                    Text("为谁保险（被保人）",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                    SizedBox(height: 12.h,),
                    Wrap(
                      spacing: 12.0, // 两个Container之间的水平间距
                      runSpacing: 10.0, // 行与行之间的垂直间距
                      children: payForList.map((length) {
                        bool? isSelected = insuredPerson.contains(length);

                        return GestureDetector(
                          onTap: () {
                            // 处理点击事件
                            setState(() {
                              if (isSelected) {
                                //如果已经被选中，则移除
                                insuredPerson="";

                              } else {
                                // 如果未被选中且未达到最大选择数量，则添加
                                insuredPerson=length;

                              }
                            });
                          },
                          child: Container(
                            width:(screenSize.width-100.w)/3, // Container宽度
                            height: 30.h, // Container高度，使其成为正方形
                            decoration: BoxDecoration(
                              border: Border.all(
                                color: isSelected ?MyColors.themeColor:MyColors.backgreyColor , // 边框颜色
                                width: 1.0, // 边框宽度
                              ),
                              color: isSelected ? Color.fromRGBO(251, 236, 228, 1) : MyColors.backgreyColor, // 根据状态决定颜色
                              borderRadius: BorderRadius.circular(3.0), // 设置Container的圆角
                            ),
                            child: Center(
                              child: Text(
                                length,
                                style: TextStyle(
                                  fontSize: 13.sp,
                                  color: isSelected ?MyColors.themeColor:Colors.black, // 文字颜色为白色
                                ),
                              ),
                            ),
                          ),
                        );
                      }).toList(),
                    ),
                    if(insuredPerson!="同投保人")
                    SizedBox(height: 20.h,),
                    if(insuredPerson!="同投保人")
                    Column(
                      children: [
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child:Text(insuredPerson=="其他-个人"?"姓名":"公司名称",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:insuredPerson=="其他-个人"?'请输入姓名': '请输入企业名称',
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _forNameText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayForMesList[0]=value;
                                  });
                                },
                              ),
                            ),
                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child: Text(insuredPerson=="其他-个人"?"身份证":"统一社会信用代码",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:insuredPerson=="其他-个人"?'请输入身份证号': '请输入信用代码',
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _forNumText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayForMesList[1]=value;
                                  });
                                },
                              ),
                            ),

                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                        Row(
                          children: [
                            Container(
                              width: 80.w,
                              child: Text("手机号",style: TextStyle(color: Colors.black,fontSize: 14.sp),),

                            ),
                            SizedBox(width: 30.w,),
                            Container(
                              width: 150.w,
                              height: 35.h,
                              child:  TextField(
                                decoration: InputDecoration(
                                  hintText:"请输入手机号",
                                  hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                  filled: true,
                                  fillColor:Colors.white,
                                  border: InputBorder.none,
                                  alignLabelWithHint: true,
                                  contentPadding: EdgeInsets.symmetric(vertical:9.5.h, horizontal: 0.0.w),
                                ),
                                // keyboardType: TextInputType.number,
                                controller: _payPhoneText,
                                textAlign: TextAlign.left,
                                style: TextStyle(color: Colors.black),
                                onChanged: (value) {
                                  setState(() {
                                    PayForMesList[2]=value;
                                  });
                                },
                              ),
                            ),

                          ],
                        ),
                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                      ],
                    ),
                  ],
                ),
              ),

              Container(
                margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
                padding: EdgeInsets.only(bottom: 18.h,),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.all(Radius.circular(10))),
                child: Column(
                  children: [
                    Container(
                      decoration: BoxDecoration(
                          color: Color.fromRGBO(251, 236, 228, 1),
                          borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))),
                      height: 30.h,child: Center(child: Text("免赔率/额",style: TextStyle(color: MyColors.themeColor),),),),
                    SizedBox(height: 18.h,),
                    Container(
                      padding: EdgeInsets.only(left: 10.w,right: 10.w),
                      child: Text("1. 每次事故绝对免赔额为RMB 5,000.00或损失金额的10%，两者以高者为准。\n2. 火灾、爆炸、倾覆事故的每次事故绝对免赔额为RMB 20,000.00或损失金额的20%，两者以高者为准。\n3. 易碎品及液体货物，每次事故绝对免赔额为整批货物价值的5%元或损失金额的 30 ％，两者以高者为准。\n4. 每车次载重不得超过国家规定标准，如超载运输不论何种事故发生货损，乙方均将定损金额按规定载重量与实际重量的比例再计算赔付，最高扣货物损失金额的30%为限。\n5. 货物装载违反装载规定，因超长、超宽、超高原因造成事故导致货物损失，每次事故免赔率为货物损失金额的30%。"
                      ,style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                    ),
                  ],
                ),
                ),
              SizedBox(height: 10.h,),
              Container(
                margin: EdgeInsets.only(left: 10, right: 10),
                child: Row(
                  children: [
                    Column(
                      children: [
                        IconButton(
                          onPressed: () => {
                            setState(() {
                              if (isAgree == "1") {
                                isAgree = "0";
                              } else {
                                isAgree = "1";
                              }
                            })
                          },
                          icon:isAgree == "0" ? Icon(Icons.radio_button_unchecked): Icon(Icons.radio_button_checked),
                          color: isAgree == "1" ? Colors.orange : Colors.grey,
                        ),
                        SizedBox(height: 25.h,),
                      ],
                    ),
                    Container(
                      width: 290.w,
                      child:  RichText(
                        text: TextSpan(children: [

                          TextSpan(
                              text: '我已阅读并同意 ',
                              style: TextStyle(fontSize: 12.sp, color: Colors.black54,)),
                          TextSpan(
                              text: '《投保须知》',
                              style: TextStyle(fontSize:12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),
                          TextSpan(
                              text: '《保险条款》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),

                          TextSpan(
                              text: '《免责条款》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),
                          TextSpan(
                              text: '《客户告知书》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),
                          TextSpan(
                              text: '《保险经济服务委托书》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),
                          TextSpan(
                              text: '《保险经济平台服务协议》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  // 查看 服务条款
                                }),

                        ]),
                      ),
                    ),

                  ],
                ),

              ),
            ],
          ),
          ),
          Container(height: 85.h,color: Colors.white,width: screenSize.width,
          padding: EdgeInsets.only(left: 15.w,bottom: 40.h,right: 15.w,top: 10.h),
          child: BrnSmallMainButton(
            bgColor: MyColors.themeColor,
            radius: 30,
            textColor: Colors.white,
            fontSize: 16.sp,
            fontWeight: FontWeight.w600,
            title: '立即投保',
            onTap: () {
              if(isAgree=="0"){
                BrnToast.show('请阅读并同意协议须知', context);
              }else{

                if(insuredPerson=="同投保人")PayForMesList=PayPersonMesList;
                // payPerson=="本人"?insureMsgList[1]=userMap['realName']:insureMsgList[1]="司机";
                // payPerson=="本人"?insureMsgList[4]="shipper":insureMsgList[4]="driver";
                // insuredPerson=="本人"?insureMsgList[2]=userMap['realName']:insureMsgList[2]="司机";

                chooseMoney.contains("万")?insureMsgList[0]=chooseMoney:
                insureMsgList[0]=chooseMoney+"万";
                insureMsgList[1]=PayPersonMesList;
                insureMsgList[2]=PayForMesList;
                insureMsgList[3]=payPerson;
                insureMsgList[4]=insuredPerson;
                Navigator.pop(context,insureMsgList);
              }
            },
          ),),
        ],
      ),
    );
  }
}

